<?php

include_once 'DAO/CityDAO.class.php';
include_once 'DAO/UserDAO.class.php';

class TripsTemplate {
    
    // Dhmiourgei thn html gia mia lista apo taksidia
    function __invoke($tripsArray){
         $userDao = new UserDAO();
         $cityDao = new CityDAO();
         //$trips = $tripDao->getRecentTrips();
         $i = 0;
         if(count($tripsArray) == 0)
         {
             echo "Δεν υπάρχουν καταχωρημένα ταξίδια.";
         }
         else{
             foreach($tripsArray as $trip)
             {
                $user = $userDao->retrieveUsername($trip->userid);
                $fromdate = $trip->fromdate;
                $todate = $trip->todate;
                $fromcity = $cityDao->retrieveName($trip->fromcityid);
                $tocity =  $cityDao->retrieveName($trip->tocityid);
                $transport = $trip->transport;
                $description = $trip->description;

                echo <<< END
                <ul id=recentTrip$i>
                <li> User: $user </li>
                <li> From date: $fromdate </li>
                <li> To date: $todate </li>
                <li> From City: $fromcity </li>
                <li> To City: $tocity </li>
                <li> By: $transport </li>
                <li> Description: $description </li>
                </ul>
END;
               
            }
        }
    }
}

?>
